#!/bin/bash
#Version 0.0.1

total=`find /vagrant/webapp/runtime/swift_mailer_spool -type f |wc -l`

# Getting parameters:
while getopts "w:c:h" OPT;do
case $OPT in
"w")warning=$OPTARG;;
"c")critical=$OPTARG;;
"h")help;;
esac
done

#Comparing the result and setting the correct level:
if [[ $total -ge $critical ]]; then
   msg="CRITICAL"
   status=2
else if [[ $total -ge $warning ]]; then
   msg="WARNING"
   status=1
else
   msg="OK"
   status=0
   fi
fi

#Printing the results:

dir=$(ls -l /vagrant/webapp/runtime/swift_mailer_spool | awk '/^d/ {print $NF}')
for i in $dir
do 
  num=`find /vagrant/webapp/runtime/swift_mailer_spool/$i -type f|wc -l`
  echo -n "$i include files:$num;"
done

exit $status
